@echo off
echo Starting School Management System...

REM Check if virtual environment exists
if not exist ".venv" (
    echo Creating virtual environment...
    python -m venv .venv
)

REM Activate virtual environment
call .venv\Scripts\activate

REM Install requirements
echo Installing dependencies...
pip install -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt

REM Initialize database
echo Initializing database...
flask db upgrade

REM Start the application and open browser
echo Starting Flask application...
start http://localhost:5000
flask run --host=0.0.0.0 --port=5000

REM Keep the window open if there's an error
pause 